const express = require('express')
const cors = require('cors')

const fxRouter = require('./router/fx')
const orderRouter = require('./router/order')
const fyRouter = require('./router/fy')
const fxfyRouter = require('./router/fxfy')
const jgfyRouter = require('./router/jgfy')
const zjRouter = require('./router/zj')
const zjscRouter = require('./router/zjsc')
const zjtjRouter = require('./router/zjtj')
const scRouter = require('./router/sc')
const scscRouter = require('./router/scsc')
const sctjRouter = require('./router/sctj')
const gldzzjRouter = require('./router/gldzzj')
const gldzjsRouter = require('./router/gldzjs')
const dwRouter = require('./router/dw')
const maRouter = require('./router/xgma')
const loginRouter = require('./router/login')
const commentRouter = require('./router/comment')
const registerRouter = require('./router/register')
const GetspotRouter = require('./router/SpotGet')
const DelspotRouter = require('./router/SpotDel')
const AddspotRouter = require('./router/SpotAdd')
const SetspotRouter = require('./router/SpotSet')
const addstrategyRouter = require('./router/addstrategy')
const strategyRouter = require('./router/strategy')
const delstrategyRouter = require('./router/delstrategy')
const changepraiseRouter = require('./router/changepraise')
const roomRouter = require('./router/room')
const userlistRouter = require('./router/userlist')

const app = express()

app.listen(3000, () => {
  console.log('服务器启动成功')
})

app.use(
  express.urlencoded({
    extended: true,
  })
)
app.use(cors())

app.use('/user', maRouter)
app.use('/fx', fxRouter)
app.use('/order', orderRouter)
app.use('/fy', fyRouter)
app.use('/fxfy', fxfyRouter)
app.use('/jgfy', jgfyRouter)
app.use('/zj', zjRouter)
app.use('/zjsc', zjscRouter)
app.use('/zjtj', zjtjRouter)
app.use('/sc', scRouter)
app.use('/scsc', scscRouter)
app.use('/sctj', sctjRouter)
app.use('/gldzzj', gldzzjRouter)
app.use('/gldzjs', gldzjsRouter)
app.use('/dw', dwRouter)
app.use('/user', maRouter)
app.use('/login', loginRouter)
app.use('/comment', commentRouter)
app.use('/register', registerRouter)
app.use('/spot/get', GetspotRouter)
app.use('/spot/del', DelspotRouter)
app.use('/spot/add', AddspotRouter)
app.use('/spot/set', SetspotRouter)
app.use('/users/addstrategy', addstrategyRouter)
app.use('/users/strategy', strategyRouter)
app.use('/users/delstrategy', delstrategyRouter)
app.use('/users/changepraise', changepraiseRouter)
app.use('/room', roomRouter)
app.use('/userlist', userlistRouter)

app.use((err, req, res, next) => {
  console.log(err)
  res.status(500).send({ code: 500, msg: '服务器错误' })
})
